package com.cskaoyan.controller;

import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.domain.MarketUser;
import com.cskaoyan.domain.OrderStatus;
import com.cskaoyan.service.OrderService;
import com.cskaoyan.service.WxOrderService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.Serializable;
import java.util.HashMap;

/**
 * @author stone
 * @date 2023/06/16 14:33
 */
@RestController
@RequestMapping("wx/user")
public class WxUserController {
    @Autowired
    WxOrderService orderService;
    @RequestMapping("index")
    public BaseRespVo index() {
        Subject subject = SecurityUtils.getSubject();
        MarketUser principal = (MarketUser) subject.getPrincipal();
        Integer userId = principal.getId();
        Integer countByStatus401 = orderService.getCountByStatus((short) 401);
        Integer countByStatus402 = orderService.getCountByStatus((short) 402);
        Integer uncomment = countByStatus401+countByStatus402;
        Integer unpaid = orderService.getCountByStatus((short) 101);
        Integer unrecv = orderService.getCountByStatus((short) 301);
        Integer unship = orderService.getCountByStatus((short) 201);
        OrderStatus order = new OrderStatus();
        HashMap<String, Object> map = new HashMap<>();
        map.put("uncomment",uncomment);
        map.put("unpaid",unpaid);
        map.put("unrecv",unrecv);
        map.put("unship",unship);
        order.setOrder(map);
        return BaseRespVo.ok(order);
    }
}
